- name: d8.monitoring-custom.warnings
  rules:
  - alert: CustomServiceMonitorFoundInD8Namespace
    expr: |
      max(d8_monitoring_custom_unknown_service_monitor_total{job="deckhouse"} > 0)
    labels:
      severity_level: "9"
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      plk_grouped_by__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      description: |-
        There are ServiceMonitors in Deckhouse namespace that were not created by Deckhouse.

        Use the following command for filtering: `kubectl get servicemonitors --all-namespaces -l heritage!=deckhouse`.

        They must be moved from Deckhouse namespace to user-spec namespace (was not labeled as `heritage: deckhouse`).

        The detailed description of the metric collecting process is available in the [documentation](https://deckhouse.io/documentation/v1/modules/300-prometheus/faq.html).
      summary: There are ServiceMonitors in Deckhouse namespace that were not created by Deckhouse.

  - alert: CustomPodMonitorFoundInCluster
    expr: |
      max(d8_monitoring_custom_unknown_pod_monitor_total{job="deckhouse"} > 0)
    labels:
      severity_level: "9"
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      plk_grouped_by__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      description: |-
        There are PodMonitors in Deckhouse namespace that were not created by Deckhouse.

        Use the following command for filtering: `kubectl get podmonitors --all-namespaces -l heritage!=deckhouse`.

        They must be moved from Deckhouse namespace to user-spec namespace (was not labeled as `heritage: deckhouse`).

        The detailed description of the metric collecting process is available in the [documentation](https://deckhouse.io/documentation/v1/modules/300-prometheus/faq.html).
      summary: There are PodMonitors in Deckhouse namespace that were not created by Deckhouse.

  - alert: D8CustomPrometheusRuleFoundInCluster
    expr: |
      max(d8_monitoring_custom_unknown_prometheus_rules_total{job="deckhouse"} > 0)
    labels:
      severity_level: "9"
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      plk_grouped_by__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      description: |-
        There are PrometheusRules in the cluster that were not created by Deckhouse.

        Use the following command for filtering: `kubectl get prometheusrules --all-namespaces -l heritage!=deckhouse`.

        They must be abandoned and replaced with the `CustomPrometheusRules` object.

        Please, refer to the [documentation](https://deckhouse.io/documentation/v1/modules/300-prometheus/faq.html#how-do-i-add-alerts-andor-recording-rules) for information about adding alerts and/or recording rules.
      summary: There are PrometheusRules in the cluster that were not created by Deckhouse.

  - alert: D8OldPrometheusCustomTargetFormat
    expr: |
      max(d8_monitoring_custom_old_prometheus_custom_targets_total{job="deckhouse"} > 0)
    labels:
      severity_level: "9"
    annotations:
      plk_protocol_version: "1"
      plk_markup_format: "markdown"
      plk_create_group_if_not_exists__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      plk_grouped_by__d8_deprecated_prometheus_functionality_in_used: "D8DeprecatedPrometheusFunctionalityIsUsed,prometheus=deckhouse"
      description: |-
        Services with the `prometheus-custom-target` label are used to collect metrics in the cluster.

        Use the following command for filtering: `kubectl get service --all-namespaces --show-labels | grep prometheus-custom-target`.

        Note that the label format has changed. You need to change the `prometheus-custom-target` label to `prometheus.deckhouse.io/custom-target`.

        For more information, refer to the [documentation](https://deckhouse.io/documentation/v1/modules/300-prometheus/faq.html).
      summary: Services with the `prometheus-custom-target` label are used to collect metrics in the cluster.
